import json


data = [
{"name":"王哲铭","age":20,"profession":"信息工程","hometown":"湖北"},
{"name":"杨幂","age":18,"profession":"表演艺术","hometown":"北京"},
{"name":"杨超越","age":18,"profession":"音乐创作","hometown":"江苏"},
]
f1 = open('stu.json', 'w')
json.dump(data, f1)
print('成功写入数据到文件！\n')
f1.close()

f2 = open('stu.json', encoding='utf-8')
line = f2.readline()
d = json.loads(line)
print(d)
for i in d:
    name = i['name']
    age = i['age']
    profession = i['profession']
    hometown = i['hometown']
    print(name, age, profession, hometown)
f2.close()

